#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<bitset>
#include<queue>
#include<stack>

#define LET(x,a) typeof(a) x(a)
#define FOR(i,a,b) for(LET(i,a);i!=(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(it,v) FOR(it,(v).begin(),(v).end())
#define sz size()
#define pb push_back
#define mp make_pair
#define cs c_str()

#define GI ({int _;scanf("%d",&_);_;})
#define COUNT(f,x) ({int _=0;f _+=(x);_;})
#define EXISTS(f,x) ({int _=0;f if(x) {_=1;break;}_;})
#define ALL(f,x) (!EXISTS(f,!(x)))
#define MIN(f,x) ({LL _=LINF;f _<?=(x);_;})
#define MAX(f,x) (-MIN(f,-(x)))

typedef long long LL;
typedef long int LI;
struct PI
{
	int x,y,z;
};
struct plane
{
		int A,B,C,D;
		int f(PI p)
		{
			int res = A*p.x+B*p.y+C*p.z-D;
			return res==0? 0 : res/abs(res);
		}
		int liesin(PI p,PI pts[])
		{
			int minx = -1000,maxx=1000,miny=-1000,maxy=1000,minz=-1000,maxz=1000;
			REP(i,4) { 
						minx <?= pts[i].x; maxx >?= pts[i].x;
						miny <?= pts[i].y; maxy >?= pts[i].y;
						minz <?= pts[i].z; maxz >?= pts[i].z;
					}
			if(minx<p.x && p.x<maxx && miny<p.y && p.y<maxy && minz<p.z && p.z<maxz) return true;
			else return false;
						
			
		}
		PI intersection(PI p1,PI p2)
		{
			int a = p2.x-p1.x;
			int b = p2.y-p1.y;
			int c = p2.z-p1.z;
			int v = A*a+B*b+C*c;
			int t = (D-f(p1))/v;
			PI res;
			res.x = a*t+p1.x;
			res.y = b*t+p1.x;
			res.x = a*t+p1.x;
			return res;
		}
};

using namespace std;
int main()
{
		int t;
		cin>>t;
		while(t--)
		{
				PI p1[4],p2[4];
				REP(i,4) cin>>p1[i].x>>p1[i].y>>p1[i].z;
				REP(i,4) cin>>p2[i].x>>p2[i].y>>p2[i].z;
				plane P1,P2;
				int x1 = p1[0].x,x2 = p1[1].x,x3 = p1[2].x,x4 = p1[3].x;
				int y1 = p1[0].y,y2 = p1[1].y,y3 = p1[2].y,y4 = p1[3].y;
				int z1 = p1[0].z,z2 = p1[1].z,z3 = p1[2].z,z4 = p1[3].z;
				
				P1.A = y1*(z2-z3)+y2*(z3-z1)+y3*(z1-z2);
				P1.B = z1*(x2-x3)+x2*(x3-x1)+z3*(x1-x2);
				P1.C = x1*(y2-y3) + x2*(y3-y1) + x3*(y1-y2);
				P1.D = x1*(y2*z3-y3*z2) + x2*(y3*z1-y1*z3) + x3*(y1*z2-y2*z1);
				
				x1 = p2[0].x,x2 = p2[1].x,x3 = p2[2].x,x4 = p2[3].x;
				y1 = p2[0].y,y2 = p2[1].y,y3 = p2[2].y,y4 = p2[3].y;
				z1 = p2[0].z,z2 = p2[1].z,z3 = p2[2].z,z4 = p2[3].z;
				
				P2.A = y1*(z2-z3)+y2*(z3-z1)+y3*(z1-z2);
				P2.B = z1*(x2-x3)+x2*(x3-x1)+z3*(x1-x2);
				P2.C = x1*(y2-y3) + x2*(y3-y1) + x3*(y1-y2);
				P2.D = x1*(y2*z3-y3*z2) + x2*(y3*z1-y1*z3) + x3*(y1*z2-y2*z1);
				
				int e = 0,f=1;
				int cnt = 0;
				REP(i,4)
				{
					
					PI int_pt = P1.intersection(p2[e],p2[f]);
					if(P1.f(p2[e])*P1.f(p2[f])==-1 || P1.f(p2[e])*P1.f(p2[f])==0 && P1.liesin(int_pt,p1)) { cnt ++; e=e+1; f=(f+1)%4; }
				}
				if(cnt==1) cout<<"Yes\n";
				else cout<<"No\n";
		}
        return 0;
}
